package cn.biplam.front.callback;

import cn.biplam.common.wrapper.ErrorMessage;
import cn.biplam.common.wrapper.Result;
import cn.biplam.common.wrapper.UserInfo;
import cn.biplam.front.html.base.HtmlWindow;
import cn.biplam.front.template.base.Anchor;

/**
 * 超级连接描述绑定器
 * @author Administrator
 *
 */
public class AnchorCallBack implements CallBack{
	
	private String sFieldName;
	private String sAnchorTitle;
	
	/**
	 * 创建超级连接描述绑定器
	 * @param sFieldName   绑定字段名称
	 * @param sAnchorTitle 超级连接标题
	 */
	public AnchorCallBack(String sFieldName,String sAnchorTitle){
		this.sFieldName = sFieldName;
		this.sAnchorTitle = sAnchorTitle;
	}
	
	/**
	 * 创建超级连接描述绑定器
	 * @param sFieldName   绑定字段名称
	 * @param sAnchorTitle 超级连接标题
	 */
	public AnchorCallBack(Object sFieldName,String sAnchorTitle){
		this(String.valueOf(sFieldName),sAnchorTitle);
	}
	
	public HtmlWindow[] getGroup(Result data, String homeUrl, UserInfo user) throws ErrorMessage{
		HtmlWindow[] total = new HtmlWindow[1];
		String fieldValue = data.getString(sFieldName);
		HtmlWindow typeDesc = new Anchor(null,fieldValue,null,sAnchorTitle).get();
		total[0] = typeDesc;
		return total;
	}
}
